import {
  Controller,
  Inject,
  Get,
  Query,
  Body,
  Post,
  Param,
  Del,
} from '@midwayjs/core';
import { CopyRecordService } from '@service/jx3/copyRecord.service';
import { ListCopyRecordDTO } from '@dto/jx3/copyRecord.dto';
import { BusinessType, Log } from '@decorator/log.decorator';

@Controller('/jx3/copyRecord')
export class PostController {
  @Inject()
  CopyRecordService: CopyRecordService;

  // 获取列表
  @Get('/list')
  async list(@Query() queryParams: ListCopyRecordDTO) {
    return await this.CopyRecordService.list(queryParams);
  }

  // 获取我的副本记录列表
  @Get('/myList')
  async myList(@Query() queryParams: ListCopyRecordDTO) {
    return await this.CopyRecordService.myList(queryParams);
  }

  // 统计周
  @Get('/countWeek')
  async countWeek(@Query() queryParams: ListCopyRecordDTO) {
    return await this.CopyRecordService.countWeek(queryParams);
  }

  // 统计周
  @Get('/countTotal')
  async countTotal(@Query() queryParams: ListCopyRecordDTO) {
    return await this.CopyRecordService.countTotal(queryParams);
  }

  // 统计月
  @Get('/countMonth')
  async countMonth(@Query() queryParams: ListCopyRecordDTO) {
    return await this.CopyRecordService.countMonth(queryParams);
  }

  // 新增
  @Log({ title: '副本记录新增', businessType: BusinessType.ADD })
  @Post('/add')
  async create(@Body() CopyRecord: any) {
    return await this.CopyRecordService.create(CopyRecord);
  }

  // 删除
  @Log({ title: '副本记录删除', businessType: BusinessType.REMOVE })
  @Del('/:CopyRecordId')
  async delete(@Param('CopyRecordId') CopyRecordId: string) {
    return await this.CopyRecordService.delete(CopyRecordId);
  }

  // 修改
  @Log({ title: '副本记录修改', businessType: BusinessType.EDIT })
  @Post('/update')
  async update(@Body() CopyRecord: any) {
    return await this.CopyRecordService.update(CopyRecord);
  }

  // 获取副本记录详情
  @Get('/:CopyRecordId')
  async get(@Param('CopyRecordId') CopyRecordId: string) {
    return await this.CopyRecordService.detail(CopyRecordId);
  }
}
